package com.beautiful.xin.list;

/**
 * @author xuqingxin 2021/7/8 10:51 上午
 */
public class ListNodeReverser {

    public static void main(String[] args) {

    }

    public static Node reverser(Node node) {
        Node newNode = null;
        Node cur = node;

        while (cur != null) {
            Node next = cur.getNext();
            cur.setNext(newNode);
            newNode = cur;
            cur = next;

        }
        return newNode;
    }


    public static Node r1(Node node){
        Node n = null;
        Node cur = node;
        while (cur!=null){
            Node next = cur.getNext();
            cur.setNext(n);
            n = cur;
            cur = next;

        }
        return n;
    }

public static Node r2(Node node){
        Node newN = null;
        Node cur = node;
        while (cur != null){
            Node next = cur.getNext();
            cur.setNext(newN);
            newN = cur;
            cur = next;
        }
        return newN;
}








}

class Node {
    private int value;
    private Node next;

    public Node(int value, Node next) {
        this.value = value;
        this.next = next;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    public Node getNext() {
        return next;
    }

    public void setNext(Node next) {
        this.next = next;
    }
}